﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.peddlerUI {
    import flash.display.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import org.aswing.geom.*;
    import Display.CollectionsUI.*;
    import Modules.peddler.*;
    import org.aswing.ext.*;
    import Display.aswingui.*;

    public class PeddlerBarView extends GenericDialogView {

        private var m_model:VectorListModel;
        private var m_gridList:GridList;
        private var m_mainPanel:JPanel;
        private var m_listPanel:JPanel;

        public function PeddlerBarView(_arg1:Dictionary, _arg2:String="", _arg3:String="", _arg4:int=0, _arg5:Function=null){
            super(_arg1, _arg2, _arg3, _arg4, _arg5);
        }
        override protected function makeBackground():void{
        }
        override protected function makeCenterPanel():void{
            this.m_mainPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP, -15);
            var _local1:DisplayObject = m_assetDict["dialog_bg"];
            this.m_mainPanel.setBackgroundDecorator(new MarginBackground(_local1));
            this.m_listPanel = ASwingHelper.makeSoftBoxJPanel();
            this.m_model = new VectorListModel();
            var _local2:GridListCellFactory = this.createCellFactory();
            this.m_gridList = new GridList(this.m_model, _local2, CollectionPanelPopout.MAX_SLOTS, 1);
            this.m_gridList.setPreferredHeight(90);
            this.setPreferredWidth(580);
            this.m_listPanel.appendAll(ASwingHelper.horizontalStrut(4), this.m_gridList);
            ASwingHelper.prepare(this.m_listPanel);
            this.m_mainPanel.append(this.m_listPanel);
            ASwingHelper.prepare(this.m_mainPanel);
            this.append(this.m_mainPanel);
            ASwingHelper.prepare(this);
        }
        protected function createCellFactory():GridListCellFactory{
            return (new PeddlerCellFactory(new IntDimension(74, 80)));
        }
        public function getCell(_arg1:int):PeddlerCell{
            var _local2:PeddlerCell = (this.m_gridList.getCellByIndex(_arg1) as PeddlerCell);
            return (_local2);
        }
        public function setUpDataForDialog(_arg1:Array):void{
            this.preSetupData();
            this.setUpDataRightNow(_arg1);
            this.m_gridList.setPreferredWidth(((74 * _arg1.length) + 8));
        }
        public function updateCell(_arg1:PeddlerModel):void{
            var _local4:PeddlerModel;
            var _local5:PeddlerCell;
            var _local2:Array = this.m_model.toArray();
            var _local3:int;
            while (_local3 < _local2.length) {
                _local4 = _local2[_local3];
                if (_local4.peddlerId == _arg1.peddlerId){
                    _local5 = this.getCell(_local3);
                    _local5.setCellValue(_arg1);
                };
                _local3++;
            };
        }
        protected function preSetupData():void{
            var _local2:PeddlerCell;
            var _local1:int;
            while (_local1 < this.m_model.getSize()) {
                _local2 = (this.m_gridList.getCellByIndex(_local1) as PeddlerCell);
                _local2.revalidate();
                _local1++;
            };
            this.m_model.clear();
        }
        protected function setUpDataRightNow(_arg1:Array):void{
            var _local3:*;
            var _local2:int;
            while (_local2 < CollectionPanelPopout.MAX_SLOTS) {
                if (_local2 < _arg1.length){
                    _local3 = _arg1[_local2];
                    if (_local3){
                        this.m_model.append(_local3);
                    };
                };
                _local2++;
            };
        }

    }
}//package Display.peddlerUI 
